Memory alone isn't enough — AI tools forget constraints, ignore decisions, and break what works. SpecLock is the AI Constraint Engine that gives your AI memory + active enforcement.
Proof: SpecLock stops Bolt from breaking your code.
Real tests on a live Bolt.new project. Auth files locked, database locked to Supabase. Here's what happens when Bolt tries to violate constraints.
Test 1 — Locked Change Blocked
"Add social media login to auth page"
User:"Add social media login to auth page"Bolt: I cannot add social media login to the auth page.The auth files are locked with the constraint"Never modify auth files."SpecLock detected a HIGH conflict: - Direct keyword match on "auth" - Auth.tsx and AuthContext.tsx are guarded - Say "unlock" to remove the lock
Test 2 — Unlocked Feature Works
"Add dark theme to the app"
User:"Ok add dark theme to the app"Bolt: Checked SpecLock — no conflicts found.✓ Created theme context with dark mode✓ Added toggle button to Dashboard✓ Updated color classes✓ Build verifiedSpecLock blocks locked things.Everything else works normally.
Test 3 — Database Constraint Enforced
"Change the database to Firebase"
User:"Change the database to Firebase"Bolt: I cannot change the database to Firebase.This project has SpecLock constraints.Lock: "Database must always be Supabase— never change to another database"To use Firebase, you need to explicitlysay "unlock" to remove the database lock.
Test 4 — File-Level Guard
Bolt reads the guard inside the file
User:"Add social media login to auth"Bolt reads Auth.tsx and sees (lines 2-7):// SPECLOCK-GUARD — DO NOT MODIFY THIS FILE// LOCKED: Never modify auth filesBolt: I cannot add social media login to theAuth component. This file is locked by SpecLock."A request for features is not permission to edit."
Locked things? Blocked. Unlocked things? Work normally. One prompt to install: "Install speclock and set up project memory"
v5.4 — NEW
Project Health Dashboard — Three Numbers That Tell Your Story
Only SpecLock knows what was intended vs what was done. Drift Score, Lock Coverage, Lock Strengthener — metrics no other tool can provide. Plus: Universal Rules Sync, Incident Replay, 10 safety templates. 51 MCP tools. 991 tests.
Drift Score (0-100)
How much has your AI deviated from your architecture? Analyzes violations, overrides, reverts, lock churn, goal changes, and session gaps. The only real-time integrity metric for AI-built projects.
Scans your codebase for high-risk patterns — auth, payments, database, secrets, API routes, security — and tells you what has no lock. Auto-suggests the missing constraints.
v5.4 is live on npm and GitHub. Update with: npx speclock@latest
v5.2 — NEW
AI Patch Firewall — Every Change Gets a Verdict
Patch Gateway (v5.1) + diff-native AI Patch Firewall (v5.2). Intent review + actual diff analysis. 10 scored signals. Hard escalation rules. ALLOW / WARN / BLOCK on every change. 51 MCP tools. 991 tests across 19 suites.
🛡
Patch Gateway (v5.1)
One API call gates every change. Combines semantic conflict + lock-to-file mapping + blast radius + typed constraints into a single ALLOW/WARN/BLOCK verdict with risk score 0-100.
Input:{ description: "Add social login", files: ["src/auth/login.js"] }Output: { verdict: "BLOCK", riskScore: 85 } reasons: ["Semantic conflict with auth lock", "File in locked zone (blast: 12)"]
🔥
AI Patch Firewall (v5.2)
Reviews actual git diffs. 10 scored signals: interface breaks, protected symbol edits, dependency drift, schema changes, API route removals. Hard escalation auto-BLOCKs destructive changes.
Paste a PRD, README, or architecture doc. Gemini Flash extracts locks, typed constraints, decisions, and notes automatically. Turn messy human text into machine-enforceable constraints.
Builds a live dependency graph from imports (JS/TS/Python). Maps locks to actual files. Calculates blast radius — transitive dependents, impact %, critical paths.
Numerical, range, state, and temporal constraints with operator enforcement. "Response time ≤ 200ms", "Uptime ≥ 99.9%", "State must be production." REST API v2 + 4 MCP tools.
Included in v5.5.2 on npm and GitHub. Update with: npx speclock@latest
v4.5
Hard Enforcement — AI Can't Ignore Your Rules
SpecLock moves from advisory (warnings) to hard enforcement (blocking). When hard mode is active, the AI physically cannot proceed past a lock violation — MCP returns isError: true.
🛑
Hard Mode
Advisory warns. Hard mode blocks. MCP returns isError:true, CLI exits with code 1, HTTP returns 409. The AI cannot proceed.
🔍
Semantic Pre-Commit
Parses actual git diff content — not just filenames. Runs semantic analysis on every changed line against your locks.
🔑
Override with Reason
Locks can be overridden with justification. Every override is logged to the HMAC audit trail. Full accountability.
⚠️
Auto-Escalation
Lock overridden 3+ times? SpecLock auto-creates a pinned review note. Patterns of rule-breaking get flagged.
⚙️
Configurable Threshold
Block threshold: 0–100%. Default 70%. Only high-confidence conflicts trigger hard blocks. Low-confidence = advisory warning.
🧩
Modular Architecture
Engine refactored into focused modules: memory.js, tracking.js, conflict.js, sessions.js, enforcer.js. Clean separation of concerns.
# Enable hard enforcement
npx speclock enforce hard --threshold 70
# Now conflicts are BLOCKED, not just warned
npx speclock check "Delete patient records"
BLOCKED — Hard enforcement active. This action cannot proceed.# Override with justification (logged to audit trail)
npx speclock override lock_abc123 "Data retention policy approved by PM"
# Semantic pre-commit — analyzes code changes, not filenames
npx speclock audit-semantic
Included in v5.5.3 on npm. 51 MCP tools. 991 tests passing. Hard enforcement is here.
v4.5
Security & Access Control — Enterprise-Grade Protection
SpecLock includes API key authentication, role-based access control, and AES-256-GCM encryption. 991 tests passing across 15 suites. Built for HIPAA-compliant environments.
🔑
API Key Authentication
SHA-256 hashed API keys with sl_key_ prefix. Create, rotate, and revoke keys instantly. Only hashes are stored — keys are never persisted in plaintext.
Transparent at-rest encryption for all SpecLock data. HIPAA-compliant by default. Encryption is automatic — no workflow changes required. Keys managed via environment variables.
✅
1073 Tests · 15 Suites
Comprehensive test coverage across security, RBAC, encryption, API auth, policy-as-code, patch gateway, diff review, spec compiler, code graph, Python SDK, ROS2, and core functionality.
Install speclock and set up project memory for my app
Pro tip: Use a template for instant constraints:
npx speclock setup --goal "My app" --template nextjs
2
That's it. Bolt does the rest.
Bolt will run npx speclock setup, read the generated SPECLOCK.md rules file, and start using SpecLock automatically. It will add locks when you say "never/always/don't touch", check constraints before changes, and log what it builds. No MCP needed. No config. No paste.
Works on Bolt.new free and paid plans. No MCP support required — uses npm file-based mode.
Project Instructions
The rules that make SpecLock automatic
Copy these rules and paste them into your platform's project instructions. This tells the AI to use SpecLock on every message — no commands needed.
🔒 SpecLock Project Instructions — Copy & Paste
Where to paste (one-time setup):
Platform
Where to Paste
Auto from MCP?
Lovable
Project Settings → Knowledge
No — paste required
Claude Code
CLAUDE.md in project root
Yes — works without paste
Cursor
.cursorrules in project root
Partial — paste recommended
Windsurf
.windsurfrules in project root
Partial — paste recommended
Cline
Custom Instructions in settings
Partial — paste recommended
bolt.diy
System prompt settings
No — paste required
The rules to copy:
## SpecLock Rules (MANDATORY — follow on every message)
1. START OF EVERY CONVERSATION: Call speclock_session_briefing
FIRST. Read all locks, decisions, and goals before doing
anything else. Show a brief summary:
"🔒 Memory loaded — X locks, Y decisions."
2. BEFORE WRITING OR MODIFYING ANY CODE: Call
speclock_check_conflict with a description of what you're
about to change (e.g., "Adding payment page" or "Modifying
the auth login flow"). If a conflict is found with HIGH
confidence, STOP and tell me which lock would be violated.
Do NOT proceed unless I explicitly say to override it.
3. WHEN I SAY "lock this", "never touch this", "don't ever
change this", "this is critical", or similar: Immediately
call speclock_add_lock with my exact constraint.
Confirm with: "🔒 Locked: [constraint]"
4. AFTER COMPLETING ANY FEATURE OR SIGNIFICANT CHANGE: Call
speclock_log_change with a summary of what was built/changed
and which files were affected. Also call speclock_add_decision
if an architectural choice was made.
5. WHEN I ASK TO REMOVE OR CHANGE SOMETHING THAT WAS LOCKED:
Warn me first: "⚠️ You locked this: [constraint]. Want me
to unlock it and proceed?" Only proceed if I confirm.
6. END OF CONVERSATION: Call speclock_session_summary with
what was accomplished.
That's it. Paste once, and every chat after that will automatically use SpecLock. The AI will load your memory at the start, check constraints before changes, and log what it builds. You never have to type a SpecLock command.
"I spent a year building products with AI coding tools. Every session, my AI forgot what we agreed on. 'Never touch auth' became 'oops, I rewrote your login flow.' I chose PostgreSQL — three sessions later, the AI migrated to MongoDB. I built SpecLock because memory without enforcement is useless. Other tools remember. SpecLock is the only one that says NO when you're about to break something."